#ifndef SCREENINGPARALELO_H
#define SCREENINGPARALELO_H

#include "detColisao.hpp"

class ScreeningParalelo : public DetecColisao
{			// Algoritmo Screening
    private:
            double CellSize;
            SPHERE*** Cell;
            void CriaMatriz();
            void CriaMatrizParalelo();
            void InicializaSemaforos();
            void iniciaMatriz( REAL max_rad, REAL min_r[2], REAL max_r[2] );
            omp_lock_t *semaforos;
            MODEL *md;
	public:
        ScreeningParalelo (REAL max_rad, MODEL *pModel,ForcaResultante* t)
        {
            Cell = NULL;
            assert (&pModel->SPHList!=NULL);
            Spheres = &pModel->SPHList;
            iniciaMatriz( max_rad,pModel->BoxMin, pModel->BoxMax );
            InicializaSemaforos();
           // Memory = 0;
            //threadEsfera= new SPHERE*[omp_get_num_procs()];
            Forca = t;
            md=pModel;
        }
        ~ScreeningParalelo(){
            if (Cell != NULL) {
                for (long i = 0; i < Rows+2; i++) delete [] Cell[i];
                delete [] Cell;
            }
            for (int i=0;i<Rows;i++) omp_destroy_lock(&(semaforos[i]));
            delete semaforos;
		}
        void calcular();
};



#endif // SCREENINGPARALELO_H
